import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { resolve } from 'node:path'
import DefineOptions from 'unplugin-vue-define-options/vite'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx(), DefineOptions()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./client', import.meta.url)),
      '@utils': fileURLToPath(new URL('./client/utils', import.meta.url)),
      '@components': fileURLToPath(new URL('./client/components', import.meta.url)),
    }
  },
  server: {
    hmr: true
  },
  build: {
    lib: {
      entry: resolve(__dirname, './client/components/package/index.ts'),
      name: "modules",
      fileName: "modules"
    },
    sourcemap:true,
    rollupOptions: {
      external: ['vue'],
      output: {
        globals: {
          vue: 'Vue'
        }
      }
    }
  }
})
